#!/usr/bin/env python

import os

findStr = "::Dispatcher::Session * pSession"
repStr = "User * pUser"

for base, dirs, names in os.walk("command"):
    for name in names :
        fileName = os.path.join(base, name)
        if (fileName[-2:] != ".h" and fileName[-4:] != ".cpp") :
            continue

        print fileName

        rfd = open(fileName)
        wfd = open(fileName + ".tmp", "w")
        for line in rfd.xreadlines() :
            if (line.find(findStr) >= 0) :
                line = line.replace(findStr, repStr)
            wfd.write(line)
        wfd.close()
        rfd.close()

        os.rename(wfd.name, rfd.name)

